# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=pixman
pkgver=0.40.0
pkgrel=3
pkgdesc="Low-level pixel manipulation library"
url="https://gitlab.freedesktop.org/pixman"
arch="all"
license="MIT"
makedepends="meson libpng-dev linux-headers"
subpackages="$pkgname-static $pkgname-dev $pkgname-dbg"
source="https://gitlab.freedesktop.org/pixman/pixman/-/archive/pixman-$pkgver/pixman-pixman-$pkgver.tar.gz
	https://gitlab.freedesktop.org/pixman/pixman/-/commit/04f662a3ee0dbab1b4755a6faf491751f6f29627.patch
	"
builddir="$srcdir/pixman-pixman-$pkgver"

case "$CARCH" in
	# broken test (likely due to endianness assumptions)
	s390x) options="!check" ;;
	aarch64) simd="-Da64-neon=enabled" ;;
esac


build() {
	# We need to increase the stacksize here: https://gitlab.gnome.org/GNOME/librsvg/-/issues/595
	LDFLAGS="$LDFLAGS -Wl,-z,stack-size=2097152" abuild-meson \
		-Ddefault_library=both \
		$simd \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

check() {
	meson test -C output -t 10
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
18774e22add5c5442edede5467fa07234c2b9e57a79d88110f25424e4253c6ab0c2921e951c5686cefebf4724ff19ad053d0c28f4d2f8d642bbcf6fc71764ef6  pixman-pixman-0.40.0.tar.gz
4c383bd629dfab9dc3b491a9b06c4192b0f4fb417d62dba494b0efa622fc557ab570d24ac1ef4a9cc0a8104d383dde4f687978c5456f39290a591e34e41e31a2  04f662a3ee0dbab1b4755a6faf491751f6f29627.patch
"
